import Element from './element'
import {context} from './canvas'
/**
 * 子类 Bullet 子弹对象
 */
class Bullet extends Element {
  constructor (opts) {
    super(opts)
    this.icon = opts.icon
  }

  /**
   * 方法：fly 向上移动
   */
  fly (isMoveDown) {
    let isMove = isMoveDown || false
    this.move(0, isMove ? this.speed : -this.speed)
    return this
  }
  /**
   * 方法：draw 绘制子弹
   */
  draw () {
    context.drawImage(this.icon, this.x, this.y, this.width, this.height)
    return this
  }
}

export default Bullet
